package com.notelapierdas.objects;

import android.os.Parcel;
import android.os.Parcelable;

public class Price implements Parcelable{
	
	private int originalPrice;
	private int dealPrice;
	
	public Price(int originalPrice, int dealPrice){
		this.originalPrice = originalPrice;
		this.dealPrice = dealPrice;
	}
	
	public int getOriginalPrice() {
		return originalPrice;
	}
	public void setOriginalPrice(int originalPrice) {
		this.originalPrice = originalPrice;
	}
	public int getDealPrice() {
		return dealPrice;
	}
	public void setDealPrice(int dealPrice) {
		this.dealPrice = dealPrice;
	}
	public int getDiscount(){
		double d = dealPrice*1.0;
		double o = originalPrice*1.0;
		double i = (o-d)/o;
		return (int)(i*100);
	}
	
/////////////Parcelable//////////////////////////////
	
	public Price(Parcel in) {
		readFromParcel(in);
	}

	private void readFromParcel(Parcel in) {
		// TODO Auto-generated method stub
		originalPrice = in.readInt();
		dealPrice = in.readInt();
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		// TODO Auto-generated method stub
		dest.writeInt(originalPrice);
		dest.writeInt(dealPrice);
	}	

	@Override
	public int describeContents() {
		// TODO Auto-generated method stub
		return 0;
	}
	
	@SuppressWarnings("rawtypes")
	public static final Parcelable.Creator CREATOR =
    	new Parcelable.Creator() {
            public Price createFromParcel(Parcel in) {
                return new Price(in);
            }
 
            public Price[] newArray(int size) {
                return new Price[size];
            }
        };
	
	///////////////////////////////////////////////////////

}
